<?php
header("Content-type:text/html; charset=utf-8"); 

//提交地址
//$form_url = 'https://pay.ips.net.cn/ipayment.aspx'; //测试
$form_url = 'https://pay.ips.com.cn/ipayment.aspx'; //正式

//商户号
$Mer_code = "014740";

//商户证书：登陆http://merchant.ips.com.cn/商户后台下载的商户证书内容
$Mer_key = "36451620901856065970269330053246181842887948974683586506701057676567422219322046647065958403072037230625137727476541950060891824";

//商户订单编号
$Billno = $_POST['Billno'];

//订单金额(保留2位小数)
$Amount = number_format($_POST['Amount'], 2, '.', '');

//订单日期
$Date = date("Ymd");

//币种
$Currency_Type = $_POST['Currency_Type'];

//支付卡种
$Gateway_Type = "01";

//语言
$Lang = "GB";

//支付结果成功返回的商户URL
$Merchanturl = "http://".$_SERVER['SERVER_NAME']."/Lib/Order/IPSRMBphp/demo/OrderReturn.php";

//支付结果失败返回的商户URL
$FailUrl = "http://".$_SERVER['SERVER_NAME']."/Lib/Order/IPSRMBphp/demo/failurl.php";

//支付结果错误返回的商户URL
$ErrorUrl = $FailUrl;//暂时和失败返回同一个地址

//商户数据包
$Attach = $_POST['Attach'];

//显示金额
$DispAmount = $Amount;

//订单支付接口加密方式
$OrderEncodeType = 2;

//交易返回接口加密方式 
$RetEncodeType =12;

//返回方式
$Rettype = 0;//暂不启用无server to server

//Server to Server 返回页面URL
$ServerUrl = "";//

require "../../../../global.php";
require RootDir."/inc/dabase_mysql.php";
$mydb=new YYBDB();
$sql="select orderno from ".$SystemConest[7]."orderpaylist where orderno='".$Billno."'";

$res=$mydb->db_query($sql);

if($mydb->db_num_rows($res)<1)
{
	
	$sql="insert into ".$SystemConest[7]."orderpaylist (tourid,orderno,paytype,earnbizhong) value(".$_REQUEST['productid'].",'$Billno','环讯','RMB')";
	$mydb->db_query($sql);
	
}




//订单支付接口的Md5摘要，原文=订单号+金额+日期+支付币种+商户证书 
$SignMD5 = md5($Billno . $Amount . $Date . $Currency_Type . $Mer_key);
?>
<html>
  <head>
    <title>跳转......</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <form action="<?php echo $form_url ?>" method="post" id="frm1">
      <input type="hidden" name="Mer_code" value="<?php echo $Mer_code ?>">
      <input type="hidden" name="Billno" value="<?php echo $Billno ?>">
      <input type="hidden" name="Amount" value="<?php echo $Amount ?>" >
      <input type="hidden" name="Date" value="<?php echo $Date ?>">
      <input type="hidden" name="Currency_Type" value="<?php echo $Currency_Type ?>">
      <input type="hidden" name="Gateway_Type" value="<?php echo $Gateway_Type ?>">
      <input type="hidden" name="Lang" value="<?php echo $Lang ?>">
      <input type="hidden" name="Merchanturl" value="<?php echo $Merchanturl ?>">
      <input type="hidden" name="FailUrl" value="<?php echo $FailUrl ?>">
      <input type="hidden" name="ErrorUrl" value="<?php echo $ErrorUrl ?>">
      <input type="hidden" name="Attach" value="<?php echo $Attach ?>">
      <input type="hidden" name="DispAmount" value="<?php echo $DispAmount ?>">
      <input type="hidden" name="OrderEncodeType" value="<?php echo $OrderEncodeType ?>">
      <input type="hidden" name="RetEncodeType" value="<?php echo $RetEncodeType ?>">
      <input type="hidden" name="Rettype" value="<?php echo $Rettype ?>">
      <input type="hidden" name="ServerUrl" value="<?php echo $ServerUrl ?>">
      <input type="hidden" name="SignMD5" value="<?php echo $SignMD5 ?>">
    </form>
    <script language="javascript">
      document.getElementById("frm1").submit();
    </script>
  </body>
</html>
